/*
 * Copyright 2012 Marsrutai.lt
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lt.marsrutai.mobile.android.model;

import lt.marsrutai.mobile.android.dao.Identifier;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * Bookmark representing a whole track
 * 
 * @author Justas
 */
public class TrackBookmark extends Bookmark implements Parcelable {

    public static final Parcelable.Creator<TrackBookmark> CREATOR = new Parcelable.Creator<TrackBookmark>() {

        @Override
        public TrackBookmark createFromParcel(Parcel source) {
            return new TrackBookmark(source);
        }

        @Override
        public TrackBookmark[] newArray(int size) {
            return new TrackBookmark[size];
        }
    };

    private String transportId;

    private String scheduleId;
    private String scheduleName;
    private String scheduleTrackName;

    private String trackId;
    private String trackName;

    public TrackBookmark() {
    }

    public TrackBookmark(Parcel in) {
        super(in);

        transportId = in.readString();

        scheduleId = in.readString();
        scheduleName = in.readString();
        scheduleTrackName = in.readString();

        trackId = in.readString();
        trackName = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);

        dest.writeString(transportId);

        dest.writeString(scheduleId);
        dest.writeString(scheduleName);
        dest.writeString(scheduleTrackName);

        dest.writeString(trackId);
        dest.writeString(trackName);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Identifier
    public String getTrackId() {
        return trackId;
    }

    public void setTrackId(String trackId) {
        this.trackId = trackId;
    }

    @Identifier
    public String getTransportId() {
        return transportId;
    }

    public void setTransportId(String transportId) {
        this.transportId = transportId;
    }

    @Identifier
    public String getScheduleId() {
        return scheduleId;
    }

    public void setScheduleId(String scheduleId) {
        this.scheduleId = scheduleId;
    }

    @Identifier
    public String getScheduleName() {
        return scheduleName;
    }

    public void setScheduleName(String scheduleName) {
        this.scheduleName = scheduleName;
    }

    @Identifier
    public String getScheduleTrackName() {
        return scheduleTrackName;
    }

    public void setScheduleTrackName(String scheduleTrackName) {
        this.scheduleTrackName = scheduleTrackName;
    }

    @Identifier
    public String getTrackName() {
        return trackName;
    }

    public void setTrackName(String trackName) {
        this.trackName = trackName;
    }

    @Override
    public String toString() {
        return "TrackBookmark [scope=" + getScopeFolder() + ", trackId=" + trackId + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + ((scheduleId == null) ? 0 : scheduleId.hashCode());
        result = prime * result + ((scheduleName == null) ? 0 : scheduleName.hashCode());
        result = prime * result + ((scheduleTrackName == null) ? 0 : scheduleTrackName.hashCode());
        result = prime * result + ((trackId == null) ? 0 : trackId.hashCode());
        result = prime * result + ((trackName == null) ? 0 : trackName.hashCode());
        result = prime * result + ((transportId == null) ? 0 : transportId.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        TrackBookmark other = (TrackBookmark) obj;
        if (scheduleId == null) {
            if (other.scheduleId != null) {
                return false;
            }
        }
        else if (!scheduleId.equals(other.scheduleId)) {
            return false;
        }
        if (scheduleName == null) {
            if (other.scheduleName != null) {
                return false;
            }
        }
        else if (!scheduleName.equals(other.scheduleName)) {
            return false;
        }
        if (scheduleTrackName == null) {
            if (other.scheduleTrackName != null) {
                return false;
            }
        }
        else if (!scheduleTrackName.equals(other.scheduleTrackName)) {
            return false;
        }
        if (trackId == null) {
            if (other.trackId != null) {
                return false;
            }
        }
        else if (!trackId.equals(other.trackId)) {
            return false;
        }
        if (trackName == null) {
            if (other.trackName != null) {
                return false;
            }
        }
        else if (!trackName.equals(other.trackName)) {
            return false;
        }
        if (transportId == null) {
            if (other.transportId != null) {
                return false;
            }
        }
        else if (!transportId.equals(other.transportId)) {
            return false;
        }
        return true;
    }

}
